//
//  BKMyOrderBackGoodsCell.m
//  bestkeep
//
//  Created by mac on 16/12/18.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKMyOrderBackGoodsCell.h"
#import "BK_OD_Tool.h"
@implementation BKMyOrderBackGoodsCell


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        _applyGoodsImage = [UIImageView new];
        _applyGoodsImage.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_applyGoodsImage];
        [_applyGoodsImage mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView.mas_top).offset(10);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-10);
            make.left.mas_equalTo(self.contentView.mas_left).offset(ApplicationBackGauge);
            make.width.mas_equalTo(@(80));
        }];
        _applyGoodsDetail = [UILabel new];
        _applyGoodsDetail.textColor = [UIColor blackColor];
        _applyGoodsDetail.font = [UIFont systemFontOfSize:15.0];
        _applyGoodsDetail.numberOfLines = 2;
        _applyGoodsDetail.text = @" --- ";
        [self.contentView addSubview:_applyGoodsDetail];
        
        [_applyGoodsDetail mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView.mas_top).offset(10);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-ApplicationBackGauge);
            make.left.mas_equalTo(_applyGoodsImage.mas_right).offset(10);
        }];
        _applyGoodsParameter = [UILabel new];
        _applyGoodsParameter.textColor = [UIColor grayColor];
        
        _applyGoodsParameter.font = [UIFont systemFontOfSize:14.0];
        _applyGoodsParameter.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_applyGoodsParameter];
        [_applyGoodsParameter mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(_applyGoodsImage.mas_centerY);
            make.left.mas_equalTo(_applyGoodsImage.mas_right).offset(10);
        }];
        _applyGoodsData = [UILabel new];
        _applyGoodsData.textColor = [UIColor grayColor];
        _applyGoodsData.text = @"数量:---";
        _applyGoodsData.font = [UIFont systemFontOfSize:14.0];
        _applyGoodsData.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_applyGoodsData];
        
        [_applyGoodsData mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(_applyGoodsImage.mas_bottom).offset(0);
            make.left.mas_equalTo(_applyGoodsImage.mas_right).offset(10);
        }];
        _backButton = [UIButton new];
        _backButton.backgroundColor = [UIColor whiteColor];
        _backButton.layer.borderWidth = 0.5;
        _backButton.layer.borderColor = [UIColor grayColor].CGColor;
        [_backButton setTitle:@"申请退换货" forState:UIControlStateNormal];
        _backButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_backButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.contentView addSubview:_backButton];
        [_backButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-10);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-ApplicationBackGauge);
            make.height.equalTo(@(25));
            make.width.equalTo(@(100));
        }];
        UIView *line = [UIView new];
        line.backgroundColor =RGB(220, 220, 220);
         line.backgroundColor = ThemeBackgroundColor;
        
        [self.contentView addSubview:line];
        
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView.mas_bottom).offset(0);
            make.height.equalTo(@(1.5));
            make.left.right.equalTo(self.contentView);
        }];
    }
    return self;
}
//从退换货进入;
-(void)setModel:(order_list *)model{
    _model = model;
    [_applyGoodsImage load:model.goods_img];
    _applyGoodsDetail.text = model.goods_name;
    _applyGoodsData.text = [NSString stringWithFormat:@"数量:%@",model.goods_amount];
    if (model.propList.count>0) {
        NSString *salepropoty = @"";
        for (propList *propModel in model.propList) {
            NSString *str = [NSString stringWithFormat:@"%@:",propModel.name];
            NSString *str1 = [NSString stringWithFormat:@"%@%@",str,propModel.value];
            salepropoty = [NSString stringWithFormat:@"%@%@",salepropoty,str1];
        }
        
        _applyGoodsParameter.text = salepropoty;
        
    }
    
}
//从订单详情;

-(void)setOrdermodel:(BK_My_Order_rows_itemList_Model *)ordermodel{
    _ordermodel = ordermodel;
    [_applyGoodsImage load:ordermodel.goods_img];
    _applyGoodsDetail.text = ordermodel.goods_name;
    _applyGoodsData.text = [NSString stringWithFormat:@"数量:%@",ordermodel.amount];
    NSString *str = ordermodel.returnFlag;
    
    _applyGoodsParameter.text = ordermodel.sale_property;
    
}

@end
